package com.gui.controller;

import com.gui.DTO.LimitDTO;
import com.gui.DTO.QuestionDTO;
import com.gui.mapper.UserMapper;
import com.gui.model.User;
import com.gui.service.LimitPageSevice;
import com.gui.service.MainVeiwService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.thymeleaf.model.IModel;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * IndexController
 *
 * @author guigu
 * @QQ 1170258867
 * @date 2020/5/26
 * @description 跳转到主页
 */
@Controller
public class IndexController {

    @Autowired
    private UserMapper usermapper;

    @Autowired
    private MainVeiwService mainVeiwService;

    @Autowired
    private LimitPageSevice limitPageSevice;

    @RequestMapping("/")
    public String index(HttpServletRequest request, Model model){

        LimitDTO limitDTO = limitPageSevice.Bulider(new LimitDTO(), 1);
        model.addAttribute("limitDTO",limitDTO);
        return "main";
    }

    @GetMapping("/page/{page}")
    public String topage(@PathVariable("page") int page,
                         HttpServletRequest request,
                         Model model){

        LimitDTO limitDTO = limitPageSevice.Bulider(new LimitDTO(), page);
        model.addAttribute("limitDTO",limitDTO);
        return "main";
    }

}
